package com.ssy.lingxi.after.sale.controller;

import com.ssy.lingxi.after.sale.api.model.constant.AgentFlagEnum;
import com.ssy.lingxi.after.sale.api.model.constant.OpenApiMethodTypeEnum;
import com.ssy.lingxi.after.sale.model.constant.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;

/**
 * 状态监测接口
 * @author 伍将
 * @date 2020/10/12
 * @version 2.0.0
 */
@RestController
@RequestMapping("/as")
public class ServiceStatusController {

    @RequestMapping("/status")
    public String status() {
        return "OK";
    }

    @RequestMapping("/test")
    public String test() throws IOException {
        String filepath = "C:/File/messages.properties";

        List<String> content = new ArrayList<>();
        for (AfterSaleTypeEnum value : AfterSaleTypeEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");


        for (CommonBooleanEnum value : CommonBooleanEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (DeliveryTypeEnum value : DeliveryTypeEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (EvaluateLevelEnum value : EvaluateLevelEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (PayExternalStateEnum value : PayExternalStateEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (PayRuleConfigurationEnum value : PayRuleConfigurationEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (RepairGoodsActionEnum value : RepairGoodsActionEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (RepairGoodsInnerStatusEnum value : RepairGoodsInnerStatusEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (RepairGoodsInnerStatusEnum value : RepairGoodsInnerStatusEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".consumerDescribe.").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (RepairGoodsInnerStatusEnum value : RepairGoodsInnerStatusEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".supplierDescribe.").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (RepairGoodsOuterStatusEnum value : RepairGoodsOuterStatusEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (RepairGoodsReasonEnum value : RepairGoodsReasonEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (ReplaceDeliveryGoodsStatusEnum value : ReplaceDeliveryGoodsStatusEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (ReplaceDeliveryGoodsStatusEnum value : ReplaceDeliveryGoodsStatusEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".consumerName.").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (ReplaceDeliveryGoodsStatusEnum value : ReplaceDeliveryGoodsStatusEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".supplierName.").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (ReplaceDeliveryGoodsTypeEnum value : ReplaceDeliveryGoodsTypeEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (ReplaceDeliveryGoodsTypeEnum value : ReplaceDeliveryGoodsTypeEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".buyerOrderName.").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (ReplaceDeliveryGoodsTypeEnum value : ReplaceDeliveryGoodsTypeEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".venderOrderName.").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (ReplaceGoodsActionEnum value : ReplaceGoodsActionEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (ReplaceGoodsInnerStatusEnum value : ReplaceGoodsInnerStatusEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (ReplaceGoodsInnerStatusEnum value : ReplaceGoodsInnerStatusEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".consumerDescribe.").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (ReplaceGoodsInnerStatusEnum value : ReplaceGoodsInnerStatusEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".supplierDescribe.").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (ReplaceGoodsOuterStatusEnum value : ReplaceGoodsOuterStatusEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (ReplaceGoodsReasonEnum value : ReplaceGoodsReasonEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (ReturnDeliveryGoodsStatusEnum value : ReturnDeliveryGoodsStatusEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (ReturnDeliveryGoodsStatusEnum value : ReturnDeliveryGoodsStatusEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".consumerName.").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (ReturnDeliveryGoodsStatusEnum value : ReturnDeliveryGoodsStatusEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".supplierName.").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (ReturnGoodsActionEnum value : ReturnGoodsActionEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (ReturnGoodsInnerStatusEnum value : ReturnGoodsInnerStatusEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (ReturnGoodsInnerStatusEnum value : ReturnGoodsInnerStatusEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".consumerDescribe.").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (ReturnGoodsInnerStatusEnum value : ReturnGoodsInnerStatusEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".supplierDescribe.").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (ReturnGoodsOuterStatusEnum value : ReturnGoodsOuterStatusEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (ReturnGoodsReasonEnum value : ReturnGoodsReasonEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (ReturnGoodsRefundInnerStatusEnum value : ReturnGoodsRefundInnerStatusEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (ReturnGoodsRefundOuterStatusEnum value : ReturnGoodsRefundOuterStatusEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (TaskAgreeEnum value : TaskAgreeEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (VerifyLogisticsEnum value : VerifyLogisticsEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (AgentFlagEnum value : AgentFlagEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        for (OpenApiMethodTypeEnum value : OpenApiMethodTypeEnum.values()) {
            String key = value.getClass().getName();
            content.add(key.substring(key.lastIndexOf(".") + 1).concat(".").concat(String.valueOf(value.getCode())).concat("="));
        }

        content.add("");

        Files.write(Paths.get(filepath), content, StandardCharsets.UTF_8);
        return "ok";
    }

}
